package LeetcodeTest_one;

public class IntToRoman_two
{
    public static void main(String[] args)
    {
        String answer=solution.intToRoman(993);
        System.out.println(answer);
    }
}
class solution {
    public static String intToRoman(int num)
    {
        StringBuffer result=new StringBuffer();
        int []Number={1000,900,500,400,100,90,50,40,10,9,5,4,1};
        String []Roman={"M","CM","D","CD","C","XC","L","XL","X","IX","V","IV","I"};
        int j=0;
        while(num>0)
        {
            while(j<Number.length)
            {
                if(num<Number[j])
                    j++;
                else
                    break;
            }
            int m = num / Number[j];
            int n = num % Number[j];
            for (int i = 1; i <= m; i++)
                result.append(Roman[j]);
            num=n;
        }
        String answer=result.toString();
        return answer;
    }
}